cap log close
log using "Z:\Angrist Work\Web Papers\Angrist_1993\Angrist1993_Table2.log", replace

*********************************************
* PROGRAM: Angrist1993_Table2
* PROGRAMMER: Simone Schaner
* PURPOSE: Recreates Table 2 of Angrist
*	(1993)
* DATE CREATED: 8/6/07
* NOTES: Updated with estimates for column 2
*	8/28/07
********************************************

clear
set mem 50m
set more off

cd "Z:\Angrist Work\Web Papers\Angrist_1993"

use soviii_ang93b

* MAKE EXTRACT -- THIS PART OF CODE IS THE SAME AS THE CODE FOR TABLE 1

g byte vietnam= q4c8==1
g byte earlyavf= q4c9==1

g byte age= (agerec==2)*22 + (agerec==3)*27 + (agerec==4)*32 + ///
	(agerec==5)*37 + (agerec==6)*42 + (agerec==7)*47 + ///
	(agerec==8)*52 + (agerec==9)*57 + (agerec==10)*62 + ///
	(agerec==11)*67
replace age=. if agerec<2 | agerec>11	

g yrsrv= (q13c==2)*1.75 + (q13c==3)*4 + (q13c==4)*8 + (q13c==5)*13
	replace yrsrv=. if q13c<2 | q13c>5

g byte female= sex==2

g entgrade= (q15a==1)*0 + (q15a==2)*8 + (q15a==3)*9 + ///
	(q15a==4)*10 + (q15a==5)*11 + (q15a==6)*12 + ///
	(q15a==7)*13 + (q15a==8)*13 + (q15a==9)*14 + ///
	(q15a==10)*15 + (q15a==11)*16 + (q15a==12)*17 + ///
	(q15a==13)*18 + (q15a>13)*-99
		replace entgrade=20 if q15b==4
		replace entgrade=0 if entgrade<0

g curgrade= (q15c==1)*0 + (q15c==2)*8 + (q15c==3)*9 + ///
	(q15c==4)*10 + (q15c==5)*11 + (q15c==6)*12 + ///
	(q15c==7)*13 + (q15c==8)*13 + (q15c==9)*14 + ///
	(q15c==10)*15 + (q15c==11)*16 + (q15c==12)*17 + ///
	(q15c==13)*18 + (q15c>13)*-99
		replace curgrade=20 if q15d==4
		replace curgrade=0 if curgrade<0

g eddif= curgrade-entgrade

g byte drafted= q10==1
g byte officer= q12==1 | q12==2
g size=cenplsz
g byte curmar= q14a==1
g byte entmar= q14b==1
g byte entvoc= q15a==7
g byte curvoc= q15c==7

g byte health= q22c==1
g byte nonwhite= racerec>1
g byte hispanic= q3b==1
g byte knowgi= q31_3==1
g byte vcomp= q35f==1
g vcompamt= q35g*(q35g<12)
g disper= q35j*(q35j<12)
g byte usevoc= q38a==1
g byte newed= q39a==1
g byte anyaid= q39d==1
g byte anyfed= q39e1==1 | q39e2==1 | q39e3==1

g byte gibill= q39e5==1
g byte veap= q39e6==1
g byte otherva= q39e7==1 | q39e8==1
g byte anyva= gibill | veap | otherva

g byte inelig= q39f==1

g spoused= (q46a==1)*0 + (q46a==2)*8 + (q46a==3)*9 + ///
	(q46a==4)*10 + (q46a==5)*11 + (q46a==6)*12 + ///
	(q46a==7)*13 + (q46a==8)*13 + (q46a==9)*14 + ///
	(q46a==10)*15 + (q46a==11)*16 + (q46a==12)*17 + ///
	(q46a==13)*18 + (q46a>13)*-99
		replace spoused=20 if q46b5==1
		replace spoused=0 if spoused<0

g byte spsvoc= q46a==7

g byte spswork= q46c==1 | q46c==1
g byte fulltime= q47a==1
g byte parttime= q47a==2
g byte unem= q47a==3
g byte outlf= q47a==3 | q47a>5

g earn86= q59a
	g lnearn= ln(earn86)
g self86= q59b
	g lnself= ln(self86)
g spsern86= q64a
g spself86= q64b

g numdep= q68a
g byte depchild= q70a==1

g mardif= curmar-entmar

g byte hs= q39b1
g byte coll_grad= q39b2==1 | q39b3==1
g byte corresp= q39b7==1
g byte voc_tech= q39b4==1
g byte ojt_appren= q39b5==1 | q39b6==1
g byte oth_train = q39b8==1 | q39b9==1 | q39b10==1 | q39b11==1


* SELECTION CRITERIA

keep if entgrade>8
keep if eddif>=0 & female==0 & (vietnam==1 | earlyavf==1)
keep if age>=32 & age<=52
keep if yrsrv~=.

keep vetwgt age agerec pser_02 pser_07 pser_08 vietnam-oth_train branch army airf marine navy coast

# delimit ;
global testvars "_Iage_37 _Iage_42 _Iage_47 _Iage_52 _Iyrsrv_2 
	_Iyrsrv_3 _Iyrsrv_4  _IageXyrs_37_2 _IageXyrs_37_3 _IageXyrs_37_4 
	_IageXyrs_42_2 _IageXyrs_42_3 _IageXyrs_42_4 
	_IageXyrs_47_2 _IageXyrs_47_3 _IageXyrs_47_4
	_IageXyrs_52_2 _IageXyrs_52_3 _IageXyrs_52_4";
	
#delimit cr
	
* COLUMN 1
xi: reg curgrade nonwhite vietnam officer drafted curmar anyva i.age*i.yrsrv
	test $testvars
* COLUMN 2
	* THIS REGRESSION REPRODUCES THE PAPER
	xi: ivreg  curgrade nonwhite vietnam officer drafted mardif anyva i.age*i.yrsrv (entgrade= coast navy airf marine)
	* THIS REGRESSION EXCLUDES THOSE WITH MISSING BRANCH DATA
	xi: ivreg  curgrade nonwhite vietnam officer drafted mardif anyva i.age*i.yrsrv (entgrade= i.branch)
	
	test $testvars
* COLUMN 3
xi: reg eddif nonwhite vietnam officer drafted mardif anyva i.age*i.yrsrv
	test $testvars
* COLUMN 4
xi: reg lnearn nonwhite vietnam officer drafted curmar curgrade i.age*i.yrsrv
	test $testvars
* COLUMN 5
xi: reg lnearn nonwhite vietnam officer drafted curmar entgrade eddif i.age*i.yrsrv
	test $testvars
* COLUMN 6
xi: reg lnearn nonwhite vietnam officer drafted curmar anyva entgrade i.age*i.yrsrv
	test $testvars
* COLUMN 7
xi: reg lnearn nonwhite vietnam officer drafted curmar anyva entgrade eddif i.age*i.yrsrv
	test $testvars

log close